<?php

class WebUser extends CWebUser
{
  // 	public $loginUrl = array('api/user/index');

  /**
   * Overrides a Yii method that is used for roles in controllers (accessRules).
   *
   * @param string $operation Name of the operation required (here, a role).
   * @param mixed $params (opt) Parameters for this operation, usually the object to access.
   * @return bool Permission granted?
   */
  public function checkAccess($operation, $params=array())
  {

    if (empty($this->id)) {
      return false;
    }

    $role = $this->getState('roles');

    if ($role === 'admin') {
      return true;
    }

    return ($operation === $role);
  }
}